package com.camunda.workflow.mapper;

import com.camunda.workflow.domain.entity.SysTenant;
import com.mybatisflex.core.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SysTenantMapper extends BaseMapper<SysTenant> {
    @Select("select tenant.* from sys_tenant tenant " +
            "    left join sys_tenant_user_role tenant_user_role on tenant.id = tenant_user_role.tenant_id " +
            "    where tenant_user_role.user_id = #{userId}")
    List<SysTenant> selectTenantsByUserId(String userId);

    @Select("select tenant.* from sys_tenant tenant " +
            "    left join sys_tenant_user_role tenant_user_role on tenant.id = tenant_user_role.tenant_id " +
            "    where tenant_user_role.role_id = #{roleId}")
    List<SysTenant> selectTenantsByRoleId(String roleId);
}
